home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_222 / plplot / src / source.zoo / Amiga.c next >
C/C++ Source or Header  |  1989-05-15  |  8KB  |  319 lines

  1. #include "plplot.h"
  2. #include <dos.h>
  3. #include <stdio.h>
  4. #include <exec/types.h>
  5. #include <exec/ports.h>
  6. #include <graphics/display.h>
  7. #include <intuition/intuition.h>
  8. #include <intuition/intuitionbase.h>
  9. #include <intuition/screens.h>
  10.  
  11. struct NewScreen NewScreen = {
  12.    0,        /* LeftEdge Position */
  13.    0,        /* TopEdge */
  14.    640,        /* Width (high-res) */
  15.    400,        /* Height (interlace) */
  16.    1,        /* Depth (1 color) */
  17.    0,1,        /* DetailPen and BlockPen */
  18.    HIRES|INTERLACE,
  19.    CUSTOMSCREEN,
  20.    NULL,        /* Use default font */
  21.    NULL,        /* Don't want a title */
  22.    NULL,        /* Gadgets?? */
  23.    NULL        /* No CustomBitMap */
  24. };
  25.     
  26. struct NewWindow NewWindow = {
  27.    0,0,640,400,
  28.    -1,-1,
  29.    MENUPICK|VANILLAKEY,
  30.    SMART_REFRESH|BACKDROP|BORDERLESS|ACTIVATE,
  31.    NULL,    /* Window Gadget Pointer */
  32.    NULL,    /* Checkmark image */
  33.    NULL,    /* No Title */
  34.    NULL,    /* My Screen Pointer (this is set below) */
  35.    NULL, /* Not a SuperBitMap */
  36.    0,0,0,0,
  37.    CUSTOMSCREEN
  38. };
  39.  
  40. struct IntuiText IText[] = {
  41.    { 0, 1, JAM1, 0, 0, NULL, "Screen to Back" },
  42.    { 0, 1, JAM1, 0, 0, NULL, "Clear Screen" },
  43.    { 0, 1, JAM1, 0, 0, NULL, "Close Screen" },
  44.    { 0, 1, JAM1, 0, 0, NULL, "Interrupt  <CTRL-C>"},
  45.    { 0, 1, JAM1, 0, 0, NULL, "Continue   <Return>"}
  46. };
  47.  
  48. struct MenuItem MenuItem[] = {
  49.    {
  50.       &MenuItem[1],
  51.       0, 0, (140 + COMMWIDTH), 9,
  52.       ITEMTEXT | COMMSEQ | ITEMENABLED | HIGHCOMP,
  53.       0,
  54.       (APTR)&IText[0],
  55.       NULL,
  56.       'F',
  57.       NULL,
  58.       NULL
  59.    },
  60.    {
  61.       &MenuItem[2],
  62.       0, 9, (140 + COMMWIDTH), 9,
  63.       ITEMTEXT | COMMSEQ | HIGHCOMP,
  64.       0,
  65.       (APTR)&IText[1],
  66.       NULL,
  67.       'C',
  68.       NULL,
  69.       NULL
  70.    },
  71.    {
  72.       NULL,
  73.       0, 18, (140 + COMMWIDTH), 9,
  74.       ITEMTEXT | COMMSEQ | HIGHCOMP,
  75.       0,
  76.       (APTR)&IText[2],
  77.       NULL,
  78.       'Q',
  79.       NULL,
  80.       NULL
  81.    },
  82.    {
  83.       &MenuItem[4],
  84.       0, 0, (140 + COMMWIDTH), 9,
  85.       ITEMTEXT | ITEMENABLED | HIGHCOMP,
  86.       0,
  87.       (APTR)&IText[3],
  88.       NULL,
  89.       NULL,
  90.       NULL,
  91.       NULL
  92.    },
  93.    {
  94.       NULL,
  95.       0, 9, (140 + COMMWIDTH), 9,
  96.       ITEMTEXT | HIGHCOMP,
  97.       0,
  98.       (APTR)&IText[4],
  99.       NULL,
  100.       NULL,
  101.       NULL,
  102.       NULL
  103.    }
  104. };
  105.     
  106. struct Menu Menu[] = {
  107.    {
  108.       &Menu[1],
  109.       0, 0, 140, 0,
  110.       MENUENABLED,
  111.       "Screen Control",
  112.       &MenuItem[0]
  113.    },        
  114.    {
  115.       NULL,
  116.       140, 0, 140, 0,
  117.       MENUENABLED,
  118.       "Graphics Control",
  119.       &MenuItem[3]
  120.    }
  121. };
  122.  
  123. extern long IntuitionBase;
  124. extern long GfxBase;
  125. static struct Screen *Screen;
  126. static struct Window *Window;
  127. static struct Border Border;
  128. static short xy[4];
  129.  
  130. /* Open Borderless Full Screen Window for Drawing */
  131. void amiini()
  132. {
  133.    LONG OpenLibrary(), OpenScreen(), OpenWindow();
  134.  
  135.    IntuitionBase = OpenLibrary("intuition.library",0);
  136.    if(IntuitionBase == NULL) {
  137.       printf("Couldn't open intuition library");
  138.       exit(1);
  139.    }
  140.     
  141.    GfxBase = OpenLibrary("graphics.library",0);
  142.    if(GfxBase == NULL) {
  143.       printf("Couldn't open graphics library");
  144.       exit(1);
  145.    }
  146.     
  147.    if((Screen = (struct Screen *)OpenScreen(&NewScreen)) == NULL) {
  148.       printf("Couldn't open custom screen");
  149.       exit(1);
  150.    }
  151.     
  152.    ShowTitle(Screen,FALSE);
  153.  
  154.    NewWindow.Screen = Screen;    /* Pointer to CustomScreen */
  155.     
  156.    if((Window = (struct Window *)OpenWindow(&NewWindow)) == NULL) {
  157.       printf("Couldn't open window.\n");
  158.       exit(1);
  159.    }
  160.     
  161.    Border.LeftEdge = 0;
  162.    Border.TopEdge = 0;
  163.    Border.FrontPen = 1;
  164.    Border.BackPen = 0;
  165.    Border.DrawMode = JAM1;
  166.    Border.Count = 2;
  167.    Border.NextBorder = NULL;
  168.    Border.XY = xy;
  169.     
  170.    SetMenuStrip(Window,Menu);
  171. }
  172.  
  173. void amitex()
  174. {
  175.    /* I don't have a text mode on the custom screen */
  176. }
  177.  
  178. void amigra()
  179. {
  180. }
  181.  
  182. void amicol(color)
  183. int color;
  184. {
  185.    /* No color support at present -- maybe in the next release */
  186. }
  187.  
  188. /* Clear the screen */
  189. void amiclr()
  190. {
  191.    SetRast(Window->RPort,0);
  192. }        
  193.  
  194. /* Draw the line.  Also check for interrupts. */
  195. void amilin(x1,y1,x2,y2)
  196. int x1, y1, x2, y2;
  197. {
  198.    int ItemNumber, MenuNumber;
  199.    ULONG class;
  200.    USHORT code, qualifier;
  201.    struct IntuiMessage *message;
  202.    struct MenuItem *Item, *ItemAddress();
  203.     struct Message *GetMsg();
  204.    void beepw();
  205.  
  206.    xy[0] = x1;
  207.    xy[1] = 399-y1;
  208.    xy[2] = x2;
  209.    xy[3] = 399-y2;
  210.     
  211.    if((xy[0] == xy[2]) && (xy[1] == xy[3]))
  212.       WritePixel(Window->RPort,xy[0],xy[1]);
  213.    else
  214.       DrawBorder(Window->RPort,&Border,0,0);
  215.     
  216.    /* Check for user abort via CTRL-C or menu ABORT selection */
  217.    /* and also Screen to Back Selection */
  218.    /* All other messages are replied to but ignored. */
  219.    while((message = (struct IntuiMessage *)
  220.                      GetMsg(Window->UserPort))!=NULL) {
  221.       class = message->Class;
  222.       code = message->Code;
  223.       qualifier = message->Qualifier;
  224.       ReplyMsg(message);
  225.       if(class == VANILLAKEY) {
  226.          if(code == 3)
  227.             beepw();
  228.       }
  229.       else if(class == MENUPICK) {
  230.          while (code != MENUNULL) {
  231.                Item = ItemAddress(Menu,code);
  232.             MenuNumber = MENUNUM(code);
  233.             ItemNumber = ITEMNUM(code);
  234.             if((MenuNumber == 0) && (ItemNumber == 0))
  235.                ScreenToBack(Screen);
  236.             else if((MenuNumber == 1) && (ItemNumber == 0))
  237.                beepw();
  238.             code = Item->NextSelect;
  239.          }
  240.       }
  241.    }
  242. }
  243.  
  244. void amitid()
  245. {
  246.    ClearMenuStrip(Window);
  247.    CloseWindow(Window);
  248.    CloseScreen(Screen);
  249. }
  250.  
  251. void beepw()
  252. {
  253.    int ItemNumber, MenuNumber;
  254.    ULONG class;
  255.    USHORT code, qualifier;
  256.    struct IntuiMessage *message;
  257.    struct MenuItem *Item, *ItemAddress();
  258.     struct Message *GetMsg();
  259.  
  260.    OnMenu(Window,SHIFTMENU(0)+SHIFTITEM(1));
  261.    OnMenu(Window,SHIFTMENU(0)+SHIFTITEM(2));
  262.    OnMenu(Window,SHIFTMENU(1)+SHIFTITEM(1));
  263.    OffMenu(Window,SHIFTMENU(1)+SHIFTITEM(0));
  264.    for(;;) {
  265.       Wait(1L << Window->UserPort->mp_SigBit);
  266.       while((message = (struct IntuiMessage *)
  267.                         GetMsg(Window->UserPort))!=NULL) {
  268.          class = message->Class;
  269.          code = message->Code;
  270.          qualifier = message->Qualifier;
  271.          ReplyMsg(message);
  272.          if(class == VANILLAKEY) {
  273.             if(code == 13) {
  274.                OffMenu(Window,SHIFTMENU(0)+SHIFTITEM(1));
  275.                OffMenu(Window,SHIFTMENU(0)+SHIFTITEM(2));
  276.                OffMenu(Window,SHIFTMENU(1)+SHIFTITEM(1));
  277.                OnMenu(Window,SHIFTMENU(1)+SHIFTITEM(0));
  278.                return;
  279.             }
  280.          }
  281.          else if(class == MENUPICK) {
  282.             while (code != MENUNULL) {
  283.                Item = ItemAddress(Menu,code);
  284.                MenuNumber = MENUNUM(code);
  285.                ItemNumber = ITEMNUM(code);
  286.                if(MenuNumber == 0) {
  287.                   if(ItemNumber == 0)
  288.                      ScreenToBack(Screen);
  289.                   else if(ItemNumber == 1)
  290.                      SetRast(Window->RPort,0);
  291.                   else if(ItemNumber == 2) {
  292.                      ClearMenuStrip(Window);
  293.                      CloseWindow(Window);
  294.                      CloseScreen(Screen);
  295.                      goto AllDone;
  296.                   }
  297.                }
  298.                else if(MenuNumber == 1) {
  299.                   if (ItemNumber == 1) {
  300.                      OffMenu(Window,SHIFTMENU(0)+SHIFTITEM(1));
  301.                      OffMenu(Window,SHIFTMENU(0)+SHIFTITEM(2));
  302.                      OffMenu(Window,SHIFTMENU(1)+SHIFTITEM(1));
  303.                      OnMenu(Window,SHIFTMENU(1)+SHIFTITEM(0));
  304.                      return;
  305.                   }
  306.                }
  307.                code = Item->NextSelect;
  308.             }
  309.          }
  310.       }
  311.    }
  312.  
  313. AllDone:
  314.    plend();
  315.    exit(1);
  316. }
  317.  
  318.  
  319.